import pygame
from Map import Map

class Animation:
    def __init__(self,rect):
        self.imageList = []
        self.live = True
        self.rect = rect
        self.step = 0
    def play(self):
        if self.step < len(self.imageList):
            self.image = self.imageList[self.step]
            self.step += 1
            Map.window.blit(self.image, self.rect)
        else:
            self.live = False
            self.step = 0


class Explode(Animation):

    def __init__(self,rect):
        # 爆炸的位置由当前子弹打中的坦克位置决定
        super(Explode, self).__init__(rect)
        self.imageList = [
            pygame.image.load('img/e1.gif'),
            pygame.image.load('img/e2.gif'),
            pygame.image.load('img/e3.gif'),
            pygame.image.load('img/e4.gif'),
            pygame.image.load('img/e5.gif'),
            pygame.image.load('img/e6.gif'),
            pygame.image.load('img/e7.gif'),
            pygame.image.load('img/e8.gif'),
            pygame.image.load('img/e9.gif'),
            pygame.image.load('img/e10.gif'),
            pygame.image.load('img/e11.gif'),
            pygame.image.load('img/e12.gif'),
            pygame.image.load('img/e13.gif'),
            pygame.image.load('img/e14.gif'),
            pygame.image.load('img/e15.gif'),
            pygame.image.load('img/e16.gif'),
        ]


